package com.qianguo.buyer.entity;

import android.os.Parcel;
import android.os.Parcelable;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * 买家订单
 *
 * @author eva
 * @date 16/6/28
 */
public class BuyerOrder implements Parcelable {

    /** 未选择支付方式 */
    public static final int PAY_UNKNOWN = 0;
    /** 微信支付 */
    public static final int PAY_WECHAT = 1;
    /** 支付宝支付 */
    public static final int PAY_ZHIFUBAO = 2;
    /** 货到付款 */
    public static final int PAY_COD = 98;
    /** 余额支付 */
    public static final int PAY_BALANCE = 99;

    /** 未支付 */
    public static final int PAY_UNDO = 0;
    /** 支付成功 */
    public static final int PAY_SUCCESS = 1;
    /** 支付失败 */
    public static final int PAY_FAILURE = 2;

    public static final int TYPE_DOING = 1;
    public static final int TYPE_FINISH = 2;
    public static final int TYPE_CANCEL = 3;

    /** 未知是否要评论 */
    public static final int EVALUATE_UNKNOWN = 0;
    /** 未评论 */
    public static final int EVALUATE_UNDO = 1;
    /** 评论完成 */
    public static final int EVALUATE_FINISH = 2;
    /** 不能评论 */
    public static final int EVALUATE_FORBIDDEN = 3;

    /** 订单号 */
    @JSONField(name = "ordersn")
    private String orderSN;

    /** 用户id */
    private String uuid;

    /** 店铺id */
    @JSONField(name = "storeid")
    private String storeId;

    /** 店铺名称 */
    @JSONField(name = "store_name")
    private String storeName;

    /** 店铺地址 */
    @JSONField(name = "store_address")
    private String storeAddress;

    /** 收货人名字 */
    @JSONField(name = "receiver_name")
    private String receiverName;

    /** 收货地址 */
    @JSONField(name = "receiver_address")
    private String receiverAddress;

    /** 收货人电话 */
    @JSONField(name = "receiver_phone")
    private String receiverPhone;

    /** 收货人备注 */
    @JSONField(name = "receiver_intro")
    private String receiverIntro;

    /** 收货验证码 */
    @JSONField(name = "receiver_yzm")
    private String receiverAuthCode;

    /** 配送时间 */
    @JSONField(name = "delivery_time")
    private String deliveryTime;

    /** 订单总价, 分 */
    private float price;

    @JSONField(name = "ps_price")
    private float deliveryPrice;

    @JSONField(name = "zf_price")
    private float payPrice;

    @JSONField(name = "coupon_price")
    private float couponPrice;

    private float balance;

    /** 付款方式代号: 0未选择支付方式,1微信支付,2支付宝支付,98货到付款,99余额支付 */
    @JSONField(name = "pay_code")
    private int payCode;

    /** 付款方式中文名称,货到付款,支付宝支付,微信支付,余额支付, 如果没有选择任何支付方式,返回值为空 */
    @JSONField(name = "pay_name")
    private String payName;

    /** 支付状态,0未支付,1支付成功,2支付失败 */
    @JSONField(name = "is_pay")
    private int isPay;

    /** 发货状态,0未知是否要发货,1待发货,2已发货,3确认收货,4虚拟商品无需发货 */
    @JSONField(name = "send_status")
    private int sendStatus;

    /** 评价状态,0未知是否要评论,1待评论,2评论完成,3不能评论 */
    @JSONField(name = "is_evaluate")
    private int isEvaluate;

    @JSONField(name = "isReturn")
    private int isReturn;

    @JSONField(name = "merchant_status")
    private int merchantStatus;

    @JSONField(name = "weigh_status")
    private int weightStatus;

    /** 下单时间,时间戳 */
    @JSONField(name = "order_time")
    private int orderTime;

    /** 订单归类,1进行中,2已完成,3已取消 */
    private int type;

    /** 订单完成时间,时间戳,如果未完成,值是0,订单流程结束就是订单完成时间,场景:1.买家收到货,2.订单被取消 */
    @JSONField(name = "order_finish_time")
    private int orderFinishTime;

    /** 展示标签,如 待接单 */
    private String tag;

    /** 标签对应文案 */
    @JSONField(name = "tag_intro")
    private String tagIntro;

    /** 商品清单 */
    @JSONField(name = "shop_info")
    private BuyerProduct[] shopInfo;

    public BuyerProduct[] getShopInfo() {
        return shopInfo;
    }

    public void setShopInfo(BuyerProduct[] shopInfo) {
        this.shopInfo = shopInfo;
    }

    public String getStoreAddress() {
        return storeAddress;
    }

    public void setStoreAddress(String storeAddress) {
        this.storeAddress = storeAddress;
    }

    public String getReceiverPhone() {
        return receiverPhone;
    }

    public void setReceiverPhone(String receiverPhone) {
        this.receiverPhone = receiverPhone;
    }

    public String getReceiverIntro() {
        return receiverIntro;
    }

    public void setReceiverIntro(String receiverIntro) {
        this.receiverIntro = receiverIntro;
    }

    public String getReceiverAuthCode() {
        return receiverAuthCode;
    }

    public void setReceiverAuthCode(String receiverAuthCode) {
        this.receiverAuthCode = receiverAuthCode;
    }

    public String getOrderSN() {
        return orderSN;
    }

    public void setOrderSN(String orderSN) {
        this.orderSN = orderSN;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getStoreId() {
        return storeId;
    }

    public void setStoreId(String storeId) {
        this.storeId = storeId;
    }

    public String getStoreName() {
        return storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }

    public String getReceiverName() {
        return receiverName;
    }

    public void setReceiverName(String receiverName) {
        this.receiverName = receiverName;
    }

    public String getReceiverAddress() {
        return receiverAddress;
    }

    public void setReceiverAddress(String receiverAddress) {
        this.receiverAddress = receiverAddress;
    }

    public String getDeliveryTime() {
        return deliveryTime;
    }

    public void setDeliveryTime(String deliveryTime) {
        this.deliveryTime = deliveryTime;
    }

    public float getPrice() {
        return price / 100;
    }

    public void setPrice(float price) {
        this.price = price;
    }

    public float getDeliveryPrice() {
        return deliveryPrice / 100;
    }

    public void setDeliveryPrice(float deliveryPrice) {
        this.deliveryPrice = deliveryPrice;
    }

    public float getPayPrice() {
        return payPrice / 100;
    }

    public void setPayPrice(float payPrice) {
        this.payPrice = payPrice;
    }

    public float getCouponPrice() {
        return couponPrice / 100;
    }

    public void setCouponPrice(float couponPrice) {
        this.couponPrice = couponPrice;
    }

    public float getBalance() {
        return balance;
    }

    public void setBalance(float balance) {
        this.balance = balance;
    }

    public int getPayCode() {
        return payCode;
    }

    public void setPayCode(int payCode) {
        this.payCode = payCode;
    }

    public String getPayName() {
        return payName;
    }

    public void setPayName(String payName) {
        this.payName = payName;
    }

    public int getIsPay() {
        return isPay;
    }

    public void setIsPay(int isPay) {
        this.isPay = isPay;
    }

    public int getSendStatus() {
        return sendStatus;
    }

    public void setSendStatus(int sendStatus) {
        this.sendStatus = sendStatus;
    }

    public int getIsEvaluate() {
        return isEvaluate;
    }

    public void setIsEvaluate(int isEvaluate) {
        this.isEvaluate = isEvaluate;
    }

    public int getIsReturn() {
        return isReturn;
    }

    public void setIsReturn(int isReturn) {
        this.isReturn = isReturn;
    }

    public int getMerchantStatus() {
        return merchantStatus;
    }

    public void setMerchantStatus(int merchantStatus) {
        this.merchantStatus = merchantStatus;
    }

    public int getWeightStatus() {
        return weightStatus;
    }

    public void setWeightStatus(int weightStatus) {
        this.weightStatus = weightStatus;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getTagIntro() {
        return tagIntro;
    }

    public void setTagIntro(String tagIntro) {
        this.tagIntro = tagIntro;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public int getOrderTime() {
        return orderTime;
    }

    public void setOrderTime(int orderTime) {
        this.orderTime = orderTime;
    }

    public int getOrderFinishTime() {
        return orderFinishTime;
    }

    public void setOrderFinishTime(int orderFinishTime) {
        this.orderFinishTime = orderFinishTime;
    }

    public boolean canPay() {
        return isPay != PAY_SUCCESS && payCode != PAY_COD && type != TYPE_CANCEL;
    }

    public BuyerOrder() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.orderSN);
        dest.writeString(this.uuid);
        dest.writeString(this.storeId);
        dest.writeString(this.storeName);
        dest.writeString(this.storeAddress);
        dest.writeString(this.receiverName);
        dest.writeString(this.receiverAddress);
        dest.writeString(this.receiverPhone);
        dest.writeString(this.receiverIntro);
        dest.writeString(this.receiverAuthCode);
        dest.writeString(this.deliveryTime);
        dest.writeFloat(this.price);
        dest.writeFloat(this.deliveryPrice);
        dest.writeFloat(this.payPrice);
        dest.writeFloat(this.couponPrice);
        dest.writeFloat(this.balance);
        dest.writeInt(this.payCode);
        dest.writeString(this.payName);
        dest.writeInt(this.isPay);
        dest.writeInt(this.sendStatus);
        dest.writeInt(this.isEvaluate);
        dest.writeInt(this.isReturn);
        dest.writeInt(this.merchantStatus);
        dest.writeInt(this.weightStatus);
        dest.writeInt(this.orderTime);
        dest.writeInt(this.type);
        dest.writeInt(this.orderFinishTime);
        dest.writeString(this.tag);
        dest.writeString(this.tagIntro);
    }

    protected BuyerOrder(Parcel in) {
        this.orderSN = in.readString();
        this.uuid = in.readString();
        this.storeId = in.readString();
        this.storeName = in.readString();
        this.storeAddress = in.readString();
        this.receiverName = in.readString();
        this.receiverAddress = in.readString();
        this.receiverPhone = in.readString();
        this.receiverIntro = in.readString();
        this.receiverAuthCode = in.readString();
        this.deliveryTime = in.readString();
        this.price = in.readFloat();
        this.deliveryPrice = in.readFloat();
        this.payPrice = in.readFloat();
        this.couponPrice = in.readFloat();
        this.balance = in.readFloat();
        this.payCode = in.readInt();
        this.payName = in.readString();
        this.isPay = in.readInt();
        this.sendStatus = in.readInt();
        this.isEvaluate = in.readInt();
        this.isReturn = in.readInt();
        this.merchantStatus = in.readInt();
        this.weightStatus = in.readInt();
        this.orderTime = in.readInt();
        this.type = in.readInt();
        this.orderFinishTime = in.readInt();
        this.tag = in.readString();
        this.tagIntro = in.readString();
    }

    public static final Creator<BuyerOrder> CREATOR = new Creator<BuyerOrder>() {
        public BuyerOrder createFromParcel(Parcel source) {
            return new BuyerOrder(source);
        }

        public BuyerOrder[] newArray(int size) {
            return new BuyerOrder[size];
        }
    };
}
